package org.shoukaiseki.supersaiyan.db.inittable.system;


import org.shoukaiseki.inittable.domain.TableColumnInfo;
import org.shoukaiseki.inittable.domain.TableIndexInfo;
import org.shoukaiseki.inittable.service.ITableBuildInfoService;
import org.shoukaiseki.kakaroto.SksDictUtils;
import org.shoukaiseki.kakaroto.annotation.TableBuild;
import org.shoukaiseki.supersaiyan.enums.SysJobCronLogFlag;

import java.util.List;

import static org.shoukaiseki.inittable.utils.SksColumnCamelCaseCommon.intColumnUnsigned;
import static org.shoukaiseki.inittable.utils.SksColumnCamelCaseCommon.uniqueId;
import static org.shoukaiseki.inittable.utils.TableColumnInfoBuilder.column;
import static org.shoukaiseki.inittable.utils.TableIndexInfoBuilder.uniqueIndex;
import static org.shoukaiseki.inittable.utils.TableInfoUtils.tableColumns;
import static org.shoukaiseki.inittable.utils.TableInfoUtils.tableIndexs;

/**
 *
 **/
@TableBuild(name = "sys_job", comment = "定时任务调度表",version = 1,primaryKey = "primary key (jobId, jobName, jobGroup)")
public class SysJobInitTable implements ITableBuildInfoService {


    @Override
    public List<TableColumnInfo> tableColumnInfoList(){
        List<TableColumnInfo> table = tableColumns(
                column("	job_id          bigint auto_increment comment '任务ID',"),
                column("	job_name        varchar(64)  default ''        not null comment '任务名称',"),
                column("	job_group       varchar(64)  default 'DEFAULT' not null comment '任务组名',"),
                column("	invoke_target   varchar(500)                   not null comment '调用目标字符串',"),
                column("	cron_expression varchar(255) default ''        null comment 'cron执行表达式',"),
                column("	misfire_policy  varchar(20)  default '3'       null comment '计划执行错误策略',")
                .description("1:立即执行,2:执行一次,3:放弃执行"),
                column("	concurrent      char         default '1'       null comment '是否并发执行',")
                        .description("0:允许,1禁止"),
                intColumnUnsigned("cron_log_flag","日志打印","0")
                        .description(SksDictUtils.getDictInfo(SysJobCronLogFlag.class)),
                column("	status          char         default '0'       null comment '状态（0正常 1暂停）',"),
                column("	create_by       varchar(64)  default ''        null comment '创建者',"),
                column("	create_time     datetime                       null comment '创建时间',"),
                column("	update_by       varchar(64)  default ''        null comment '更新者',"),
                column("	update_time     datetime                       null comment '更新时间',"),
                column("	remark          varchar(500) default ''        null comment '备注信息',"),
                null
        );

        return table;
    }

}
